package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.Depot;
import cn.wolfcode.crm.mapper.DepotMapper;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.IDepotService;
import cn.wolfcode.crm.util.PageResult;
import cn.wolfcode.crm.util.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepotServiceImpl implements IDepotService{
    @Autowired
    private DepotMapper mapper;
    public void save(Depot entity) {
        entity.setState(Depot.STATE_EXIST);
        mapper.insert(entity);
    }

    public void update(Depot entity) {
        mapper.updateByPrimaryKey(entity);
    }

    public void delete(Long id) {
        mapper.deleteByPrimaryKey(id);
    }

    public List<Depot> list() {
        return mapper.selectAll();
    }

    public Depot get(Long id) {
        return mapper.selectByPrimaryKey(id);
    }

	public PageResult query(QueryObject qo) {
		return PageUtils.query(qo, mapper);
	}

    public void changState(Long id) {
        mapper.changeState(id);
    }
}
